package org.example.Strategy;

import java.math.BigDecimal;

//订单满减策略
public class OrderFullDiscount implements OrderDiscountStrategy{
    //满减总价格
    private BigDecimal fullAmount;
    //满减优惠金额
    private BigDecimal reduction;

    public OrderFullDiscount(BigDecimal fullAmount, BigDecimal reduction) {
        this.fullAmount = fullAmount;
        this.reduction = reduction;
    }

    @Override
    public BigDecimal apply(BigDecimal subtotal) {
        return subtotal.compareTo(fullAmount)  >= 0 ? subtotal.subtract(reduction)  : subtotal;
    }
}
